//
//  ViewController.swift
//  MapDemo
//
//  Created byfqw on 2024/4/10.
//

import UIKit


class ViewController: UIViewController {

    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let map = MAMapView()
        map.frame = view.bounds
        view.addSubview(map)
        
        map.mapType = .satellite
        
        map.delegate = self
        
        let request = AMapDistrictSearchRequest()
        request.keywords = "西安"
        request.requireExtension = true
        let search = AMapSearchAPI()
        search?.delegate = self
        search?.aMapDistrictSearch(request)
        
        
//        let pol = MAPolygon(coordinates: <#T##UnsafeMutablePointer<CLLocationCoordinate2D>!#>, count: 1)
        // Do any additional setup after loading the view.
    }


}

extension ViewController: MAMapViewDelegate{
    
    func mapView(_ mapView: MAMapView!, rendererFor overlay: (any MAOverlay)!) -> MAOverlayRenderer! {
         
        if overlay.isKind(of: MAPolygon.self) {
            
            
        }
        
        return nil
    }
    
}

extension ViewController: AMapSearchDelegate{
    
    func onDistrictSearchDone(_ request: AMapDistrictSearchRequest!, response: AMapDistrictSearchResponse!) {
        let req = response
        
        NSLog("%ld", req?.count ?? 0)
    }
    
}
